from .views import image
from django.urls import path

from apps.meiduo_mall_admin.views import home, user, sku, permission, group, admins
from apps.meiduo_mall_admin.views.login import admin_obtain_jwt_token

urlpatterns = [
    # 美多商城后台管理系统——账号登录
    path("authorizations/", admin_obtain_jwt_token),

    # 日活跃用户统计
    path("statistical/day_active/", home.UserDailyActiveCountView.as_view()),
    # 日下单用户用户量统计
    path("statistical/day_orders/", home.UserDailyOrderCountView.as_view()),
    # 月增用户统计
    path("statistical/month_increment/", home.UserMonthCountView.as_view()),
    # 查询用户
    path("users/", user.UserListView.as_view()),
    # sku表id
    path("skus/simple/", image.SKUView.as_view()),
    # 获取三级分类信息
    path("skus/categories/", sku.SKUCategoriesView.as_view()),
    # 获取SPU表名数据
    path("goods/simple/", sku.GoodsSimpleView.as_view()),
    # 获取SPU商品规格信息
    path('goods/<int:pk>/specs/', sku.GoodsSpecView.as_view()),
    # 保存权限数据
    path('permission/content_types/', permission.ContentTypeAPIView.as_view()),
    # 获取权限表数据
    path("permission/simple/", group.GroupSimpleAPIView.as_view()),
    # 获取分组表数据
    path("permission/groups/simple/", admins.AdminSimpleAPIView.as_view()),

]

from rest_framework.routers import DefaultRouter

# 创建router实例
router = DefaultRouter()
# 注册路由，basename(别名)
router.register(r'skus/images', image.ImageView, basename='image')
# 拼接路由，添加到urlpatterns
urlpatterns += router.urls

# 创建router实例
router = DefaultRouter()
# 注册路由，basename(别名)
router.register(r'skus/images/<int:pk>', image.ImageView, basename='img_id')
# 拼接路由，添加到urlpatterns
urlpatterns += router.urls

# 创建router实例
router = DefaultRouter()
# 注册路由，basename(别名)
router.register(r'skus', sku.SKUModelViewSet, basename="skus")
# 拼接路由，添加到urlpatterns
urlpatterns += router.urls

# 创建router实例
router = DefaultRouter()
# 注册路由
router.register(r'permission/perms', permission.PermissionView, basename='perms')
# 将router生成的路由追加到urlpatterns中
urlpatterns += router.urls

# 创建router实例
router = DefaultRouter()
# 注册路由
router.register(r'permission/groups', group.GroupView, basename='group')
# 将router生成的路由追加到urlpatterns中
urlpatterns += router.urls

# 创建router实例
router = DefaultRouter()
# 注册路由
router.register(r'permission/groups/<int:pk>', group.GroupView, basename='groups')
# 将router生成的路由追加到urlpatterns中
urlpatterns += router.urls

# 创建router实例
router = DefaultRouter()
# 注册路由
router.register(r'permission/admins', admins.AdminView, basename='admin')
# 将router生成的路由追加到urlpatterns中
urlpatterns += router.urls

# 创建router实例
router = DefaultRouter()
# 注册路由
router.register(r'admins/<int:pk>', admins.AdminView, basename='admins')
# 将router生成的路由追加到urlpatterns中
urlpatterns += router.urls
